import { render } from '/@/utils/common/renderUtils';

export function couponTypeRender(text) {
  let color = "";
  if (text == "DISCOUNT") {
    color = "blue";
  } else if (text == "PRICE") {
    color = "green";
  } else if (text == "LARGESS") {
    color = "red";
  } 
  if (color) {
    return render.renderTag(render.renderDict(text, 'couponType'), color);
  } else {
    return ""
  }
}

export function promotionsStatusRender(record) {
  let text = record.promotionStatus || "未知", color = "red";
  if (text == "NEW") {
    color = "geekblue";
  } else if (text == "START") {
    color = "green";
  } else if (text == "END") {
    color = "red";
  } else if (text == "CLOSE") {
    color = "orange";
  }
  return render.renderTag(render.renderDict(text, 'promotionStatus'), color);
}

export function promotionsScopeTypeRender(record) {
  let text = "未知",
    color = "red";
  if (record.scopeType == "ALL") {
    text = "全品类";
    color = "default";
  } else if (record.scopeType == "PORTION_GOODS_CATEGORY") {
    text = "商品分类";
    color = "yellow";
  } else if (record.scopeType == "PORTION_SHOP_CATEGORY") {
    text = "店铺分类";
    color = "pink";
  } else if (record.scopeType == "PORTION_GOODS") {
    text = "指定商品";
    color = "magenta";
  }
  return render.renderTag(text, color);
}

export function memberPromotionsStatusRender(h, status) {
  let text = "未知",
    color = "red";
  if (status == "NEW") {
    text = "已领取";
    color = "geekblue";
  } else if (status == "USED") {
    text = "已使用";
    color = "green";
  } else if (status == "EXPIRE") {
    text = "已过期";
    color = "red";
  } else if (status == "CLOSED") {
    text = "已作废";
    color = "red";
  }
  return render.renderTag(text, color);
}
